<template>
  <div>
    <Card>
      <div class="textRight marginB10">
        <span class="marginR10">
          已选
          <span class="cBlue">{{selectMore.length}}</span>
          条数据
        </span>
        <Button
          type="primary"
          size="small"
          shape="circle"
          @click="huLAll"
          :disabled="!$app.judgeData(selectMore)"
        >
          <Icon type="md-trash" size="16" />忽略
        </Button>
      </div>

      <Table
        :data="tableData"
        :columns="columns"
        stripe
        border
        class="marginB10"
        :loading="loading"
        @on-selection-change="onSelect"
        :height="$app.winHeight-220"
      ></Table>

      <Page
        :total="total"
        show-sizer
        show-total
        show-elevator
        size="small"
        :page-size="pageSize"
        :page-size-opts="$app.pageAll.pageSizeOpts"
        :current="page"
        @on-change="loadMore"
        @on-page-size-change="changePageSize"
      ></Page>
    </Card>
    <Temp ref="Temp" :type="9" />
  </div>
</template>


<script>
import Temp from "@$@/_service/temp";
import ListWarnInfo_tmYY from "@$@/js/warnXT/ListWarnInfo_tmYY";
export default {
  name: "ListWarnInfo6",
  components: { Temp },
  data() {
    return {
      loading: true, //加载时显示转转
      total: 0, //总页数
      page: 1, //当前页码
      pageSize: $app.pageAll.pageSize, //分页条数，最低15条
      selectMore: [], //多选，选中的栏位

      //列表
      tableData: [],
      columns: []
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    //获取数据
    getData() {
      let { page, pageSize } = this;
      // 清空原本的数据
      this.loading = true;
      this.columns = [];
      this.tableData = [];
      this.selectMore = [];

      $ajax.z_getTmObjection({ page, pageSize }, resData => {
        this.loading = false;
        this.columns=ListWarnInfo_tmYY.list(this);
        this.tableData = resData.list;
        this.total = resData.total;
      });
    },
    // 加载更多
    loadMore(page) {
      this.page = page;
      this.$nextTick(() => {
        this.getData();
      });
    },
    // 数据返回条
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.page = 1;
      this.$nextTick(() => {
        this.getData();
      });
    },


    // 单个忽略
    huLA(obj){
      this.huXz({ids:JSON.stringify([obj.id])})
    },

    // 触发忽略
    huXz(obj){
      $ajax.schedule_ignoreTmObjection(obj, res => {
        $app.toast(res.msg, true);
        this.page = 1;
        this.$nextTick(() => {
          this.getData();
        });
      });
    },
    

    // 集体忽略
    huLAll() {
      let { selectMore } = this;
      if ($app.judgeData(selectMore)) {
        $app.confirm("您确定忽略所选项目?", "温馨提示", {
          yesFun: () => {
            this.huXz({ ids: JSON.stringify(selectMore) });
          }
        });
      } else {
        this.$Message.error({content: "请选择需忽略的项目"});
      }
    },
    // 多选模式触发
    onSelect(list, row) {
      let selectMore = [];
      list.forEach((val, i) => {
        selectMore.push(val.id);
      });
      this.selectMore = selectMore;
    },







    // 异议
    objection(obj) {
      this.$refs["Temp"].trademark_name = obj.trademark_name;
      this.$refs["Temp"].register_number = obj.register_number;
      this.$refs["Temp"].remark = "";
      this.$refs["Temp"].awayShop(207, "异 议");
    },

  }
};
</script>

